package com.azure.bigstore.service;

import com.azure.bigstore.entity.Wishlist;
import com.azure.bigstore.repository.WishlistRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by liuhuaibin on 2018/1/23.
 */
@Service
public class WishListService {
    @Autowired
    private WishlistRepository wishlistRepository;

    public List<Wishlist> getWishlist(Long UID){
        return wishlistRepository.findByUid(UID);
    }

    public Wishlist getWishlistItem(String id){
        return wishlistRepository.findOne(Long.valueOf(id));
    }

    public  Wishlist saveWishlistItem(Wishlist wishlist){
        return wishlistRepository.save(wishlist);
    }

    public  void deleteWishlistItem(String id){
        wishlistRepository.delete(Long.valueOf(id));
    }
}
